"""
Multi-Model Evaluation Framework

This package provides a unified framework for evaluating different types of vision-language models
in the context of Vision-and-Language Navigation (VLN) tasks.

Main Components:
- agents: Model adapters for different VLM architectures
- processors: Data preprocessing and tokenization utilities
- evaluation: VLN evaluation tools and metrics
- utilities: Common utilities and helper functions

Features:
- Unified interface for different VLM models
- Automatic attention implementation detection
- Multi-GPU evaluation support
- Habitat-Lab integration for VLN tasks
"""

# Version information
__version__ = "1.0.0"
__author__ = "Winsleo"
__description__ = "Multi-Model Evaluation Framework"

# Import main modules
from . import agents
from . import processors

# Import main classes and functions
from .agents import (
    BaseAgent,
    StreamVLNAgent,
)

from .processors import (
    BaseProcessor,
    LanguageProcessor,
    Qwen25VLProcessor,
)

from .utils import (
    detect_best_attention_implementation,
)


# Import evaluation components - use lazy import to avoid circular dependency
def get_vln_evaluator():
    """Get VLNEvaluator class (lazy import to avoid circular dependency)."""
    from .vln_eval import VLNEvaluator
    return VLNEvaluator


# Define the public API
__all__ = [
    # Core modules
    'agents',
    'processors',
    
    # Agent classes
    'BaseAgent',
    'StreamVLNAgent',
    
    # Processor classes
    'BaseProcessor',
    'LanguageProcessor',
    'Qwen25VLProcessor',
    
    # Utility functions
    'detect_best_attention_implementation',
    'get_vln_evaluator',
    
    # Version info
    '__version__',
    '__author__',
    '__description__',
]


def get_package_info():
    """Get comprehensive information about the package."""
    return {
        'name': 'multi_model_eval',
        'version': __version__,
        'description': __description__,
        'author': __author__,
        'available_modules': list(__all__),
    }


def check_dependencies():
    """Check if all required dependencies are available."""
    import importlib
    
    required_packages = [
        'torch',
        'transformers',
        'habitat',
        'numpy',
        'PIL',
    ]
    
    missing_packages = []
    available_packages = []
    
    for package in required_packages:
        try:
            importlib.import_module(package)
            available_packages.append(package)
        except ImportError:
            missing_packages.append(package)
    
    return {
        'available': available_packages,
        'missing': missing_packages,
        'all_available': len(missing_packages) == 0,
    }


# Package initialization
def _initialize_package():
    """Initialize package-level configurations and checks."""
    print(f"Initializing {__name__} v{__version__}")
    
    # Check dependencies
    deps = check_dependencies()
    if not deps['all_available']:
        print(f"Warning: Missing packages: {deps['missing']}")
        print("Some functionality may not work correctly.")
    else:
        print("✓ All required dependencies are available")
    
    print(f"Package {__name__} initialized successfully!")


# Auto-initialize when package is imported
_initialize_package()
